The present invention relates to a method for automatically generating, by a computer, a numeric simulation program for simulating a physical phenomenon by a computer, and more particularly to a method for generating a program which is suitable for substantially reducing the number of steps from the generation of the program to the analysis of the result, and a method for executing the program.
As shown in FIG. 2A, in a spatial area 21 in which two materials having different thermal conductivity coefficients, for example, concrete and iron, contact to each other, a change in an internal temperature when an initial temperature is 0.degree. C. throughout the area, left and right walls L and R are isolated for heat, and upper and lower walls U and D are fixed to 100.degree. C. may be simulated by solving a heat diffusion equation 22 in time by the computer.
The area 21 of FIG. 2A is divided into fine areas (called meshes) partially shown by broken lines, and linear equations on unknown values Fij at points (called nodes) representing the meshes, for example, vertices of the meshes, are desired from the partial differential equation 22. In FIG. 2B, a general form thereof is shown by 602. This is called discretization When the linear equations are derived for the nodes on the boundaries L and R of the area 21, a portion of the boundary condition, for example ##EQU1## is used. For the nodes on the boundaries U and D, a boundary condition F=100 is used instead of the linear equation
Simultaneous linear equations comprising the linear equations derived for various nodes are solved to determine the unknown values F at the respective nodes.
As shown in FIG. 2B, a matrix equation 600 which comprises a matrix 602 of the coefficients (aij) of the simultaneous linear equations, a string 603 of the unknown values Fij and a string 604 of constant terms bi is solved to determine the unknown values Fij. The unknown values F at points in the area which are not at the nodes are determined by the interpolation of the determined unknown values Fij.
Such simulation is effective to the design of a circuit or a device but the matrix equation to be solved changes depending on the partial differential equation, the boundary conditions, the shape of the area and the procedure of numeric calculation. The physical phenomenon is usually represented by the partial differential equation, but this equation cannot be directly described by a commonly known high level language such as Fortran.
Thus, as described in the Journal of the Information Processing Society of Japan, Vol. 26, No. 1, pp 168-180, and JP-A-60-140433, a structure of a model to be simulated such as a shape of the area 21 in which the physical phenomenon to be simulated takes place, a partial differential equation and a calculation procedure therefor are described. A simulation program which is executable by a conventional computer, which is written in the FORTRAN language and which is for calculating the coefficient matrix and the constant terms of the matrix equation and calculating a solution for the matrix equation, is automatically generated from a program written in the high level language (problem describing program) by a program generation program.
FIG. 3 shows an example of a problem describing program written in a high level language. The program 2A illustrates a program for simulating the problem shown in FIG. 2A, Generally, it comprises a series of statements each of which starts with a key word representing a component of the program and ends with a semicolumn (;). A PROG statement 31 describes a title of the simulation program to be generated, and a METHOD statement 32 describes a numeric analysis method. In the present example, it indicates a differential method (FDM). A principal portion of the present program is divided into 400A and 500A. The portion 400A which comprises the statements 33, 33A-33C, 34, 34A-34C, and 35-36 defines a structure of a model to be simulated. This program portion includes a DOMAIN statement 33 for specifying X and Y coordinates of the analysis domain, a TIME statement 33A for specifying a time domain T, a MESH statement 33B for specifying the number of divisions by which the analysis domain is divided into a number of meshes in a matrix, a TSTEP statement 33C for specifying a time step interval DLT for tracking a solution along the time axis, a REGION statement 34 for specifying a title of a partial domain of the analysis domain, for example, a boundary or an internal divided domain, a statement 34A for declaring a constant such as a thermal conductivity coefficient or a material constant, a VAR statement 34B for declaring a physical variable used in the simulation program, a COUNT statement 34C for declaring a counter variable NT which represents the number of times of iteration of the numeric calculation, a BCOND statement 35 for specifying a boundary condition, and an ICOND statement 36 for specifying an initial condition. For example, in the REGION statement 34, a boundary at X=0 and any Y (represented by * in the present problem describing program) is named as "L", and in the BCOND statement 35, the name "L" is referred so that a heat isolation condition DX(F)=0 (where DX represents a first differentiation .differential./.differential.x) is set in the boundary sides L and R by using a location identifier AT.
The program portion which starts with a SCHEME statement and ends with an END SCHEME statement describes a numerical calculation algorithm scheme to solve the problem. It is hereinafter called a scheme block. In the present example, the statement 38 means that the statement 39 following the statement 38 to the statement 39B before the statement 30 are to be executed with a varying time step DLT until the number of times of iteration NT reaches 100. The numerical calculation algorithm scheme is a method for solving a partial differentiation equation in accordance with its characteristic (time dependency (steady or non-steady), non-linear or simultaneous). Generally, there are a plurality of solution methods for one equation.
The statement 39 means that a numeric solution F of a partial differential equation included therein is to be determined by an ILUBCG method (a BCG matrix solution method is applied by using a pre-processing by an incomplete LU decomposition). The statement 39A means that the determined F is to be printed out, and the statement 39B is an assignment statement which indicates that the variable FOLD is to be substituted by the determined F for use in the next iteration.
The ITER statement 38 to the END ITER statement 30 are iteratively executed until the condition following UNTIL in the ITER statement 38 is met. In each iteration, a temperature F at one time step later is determined by the SOLVE statement 39 based on the current temperature FOLD, and the current temperature F is updated by FOLD=F. DIV and GRAD represent divergence and gradient of a differential operator, respectively. In the present language, the partial differential equation can be expressed almost as it is.
The above program is translated to a simulation program in a FORTRAN language, for example, as shown in FIG. 4 by a program generating program (not shown). The program generating program checks syntax of the program such as type of data and type of statement, checks consistency in the domain, and checks suitability and sufficiency of the initial condition and the boundary condition, and then generates the simulation program by the FORTRAN language. In FIG. 4, a portion 42 which declares a variable and a work area necessary for the execution of the program, a portion 43 which generates and pre-processes the meshes, a portion 44 which sets values designated by the constant designation statement 34A (CONST statement) and the initial condition statement 36 (ICOND statement) of FIG. 3, and a control loop 45 are generated as a main program 41. The control loop 45 comprises a CALL statement (for example, 45A) of subroutines for the execution statements 39, 39A and 39B of the SCHEME block 400A of FIG. 3, an input/output control statement (not shown) and an ITER statement execution control 45B. Following the main program, subroutines 46 corresponding to the SOLVE statement 39 and subroutines 47 for the assignment statements 39A and 39B are generated. The subroutines 46 for the SOLVE statement 39 comprise equations described by the four rules of arithmetic operations for discretizing the partial differential equations in the statement and calculating coefficients of the resulting matrix equations, and a DO loop for iteratively calculating the above values. The subroutine for one SOLVE statement or assignment statement is automatically divided into a plurality of subroutines to prevent program units from being too long.
In the prior art, the entire problem describing program including the portion (scheme block) which the user describes by a text about the numerical calculation algorithm scheme is inputted. Accordingly, the user who is not aware of the numerical calculation algorithm scheme to be used cannot utilize it. Even if the numerical calculation algorithm scheme to be used is of well known standard type, the user has to describe it for each simulation. Thus, it takes time to input the problem describing program.
The user further has to check whether the input area or the equation is correct or not, and it takes time for the check.
The entire program has to be inputted by text, and it takes time for inputting.
The check of the content of the program is limited to the syntax error and an error in the numerical calculation algorithm scheme, for example, whether the model and the numerical calculation algorithm scheme meets a requirement of solution stability or convergence, is not checked. Such an error is totally due to the user and there is no way to check for such an error but for the user to check for any error after the execution of the generated simulation program. Consequently, the check and correction of the error are delayed.
In the prior art simulation program it is not possible to interrupt the execution at a time point designated by the operator in the course of the execution of the program, for the purpose of debugging. It is also not possible to interrupt the execution to perform debugging such as detection of an error in the numerical calculation.
In the prior art, no consideration is paid to a visual check by means of graphs of the diagnostic information to determine the correctness of the calculation result and the result of diagnosis, and there is also a problem with respect to the reliability of the simulation program.